// alert('hello world in TypeScript!');

function Add(left: number, right: number): number {
	return left + right;
}

console.log(Add(1,2));

// console.log(Add('ss', 3)); // 编译error，但是也会生成对应的js

interface Shape {
    name: string;
    width: number;
    height: number;
    color?: string;
}
 
function area(shape : Shape) {
    var area = shape.width * shape.height;
    return "I'm " + shape.name + " with area " + area + " cm squared";
}
 
console.log( area( {name: "rectangle", width: 30, height: 15} ) );
console.log( area( {name: "square", width: 30, height: 30, color: "blue"} ) );

class People {
	age: number;
	private size: number;
	private color?: string;

	constructor(public name: string, left: number, right: number) {
		this.name = name;
		this.size = left*right;
	}

	show() {
		return `this people name is ${this.name} , size is ${this.size} , color is ${this.color}`
	}
}

const p = new People('xiaoming', 10, 2);

console.log(p.show())

console.log(p.name);
// console.log(p.size); // 编译error

class Student extends People {
	play: string;
	constructor(public name: string, left: number, right: number, play: string) {
		super(name, left, right);
		this.play = play;
	}

	show(){
		return `student play ${this.play}`
	}

	superShow(){
		return super.show()
	}
}

const s = new Student('db', 29, 2, 'ball');

console.log(s.show());
console.log(s.superShow());
